﻿using AntdUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ImportPlcPointPosition.Utils
{
    /// <summary>
    /// 消息弹出类
    /// </summary>
    public static class MessageUtils
    {
        /// <summary>
        /// Error消息弹出框
        /// </summary>
        /// <param name="form">当前form窗体</param>
        /// <param name="messageContent">消息内容</param>
        /// <param name="autoClose">自动关闭时间</param>
        public static void AlertError(this Form form, string messageContent, int autoClose = 3) {
            AntdUI.Message.error(form: form, text: messageContent, autoClose: autoClose);
        }

        /// <summary>
        /// Warn消息弹出框
        /// </summary>
        /// <param name="form">当前form窗体</param>
        /// <param name="messageContent">消息内容</param>
        /// <param name="autoClose">自动关闭时间</param>
        public static void AlertWarn(this Form form, string messageContent, int autoClose = 3)
        {
            AntdUI.Message.warn(form: form, text: messageContent, autoClose: autoClose);
        }

        /// <summary>
        /// Info消息弹出框
        /// </summary>
        /// <param name="form">当前form窗体</param>
        /// <param name="messageContent">消息内容</param>
        /// <param name="autoClose">自动关闭时间</param>
        public static void AlertInfo(this Form form, string messageContent, int autoClose = 3)
        {
            AntdUI.Message.info(form: form, text: messageContent, autoClose: autoClose);
        }

        /// <summary>
        /// Success消息弹出框
        /// </summary>
        /// <param name="form">当前form窗体</param>
        /// <param name="messageContent">消息内容</param>
        /// <param name="autoClose">自动关闭时间</param>
        public static void AlertSuccess(this Form form, string messageContent, int autoClose = 3)
        {
            AntdUI.Message.success(form: form, text: messageContent, autoClose: autoClose);
        }

        /// <summary>
        /// 确认对话框
        /// </summary>
        /// <param name="form">当前form窗体</param>
        /// <param name="messageContent">消息内容</param>
        /// <param name="icon">icon类型</param>
        /// <param name="title">标题</param>
        /// <returns></returns>
        public static DialogResult AlertConfirm(this Form form, string messageContent, TType icon = TType.None, string title = "温馨提示")
        {
            try
            {
                return Modal.open(form: form, title: title, content: messageContent, icon: icon);
            }
            catch (Exception ex)
            {
                //throw;
            }
            return DialogResult.None;
        }

    }

}
